package cn.cdg.mall.controller;

import cn.cdg.mall.pojo.po.TicketPO;
import cn.cdg.mall.pojo.po.UserPO;
import cn.cdg.mall.service.TicketService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ticket")
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @RequestMapping("/all")
    public List<TicketPO> selectAllTickets(@RequestBody UserPO userPO) {
        return ticketService.selectAllTickets(userPO);
    }

    @RequestMapping("/byCreateDate")
    public List<TicketPO> selectByCreateDate(@RequestParam String createDate) {
        return ticketService.selectByCreateDate(createDate);
    }

    @RequestMapping("/byTicketID")
    public TicketPO selectOneByTicketNo(@RequestParam long TicketNo) {
        return ticketService.selectOneByTicketNo(TicketNo);
    }

    @RequestMapping("/add")
    public boolean addTicket(@RequestBody TicketPO ticket) {
        return ticketService.addTicket(ticket);
    }

}